package pl.edu.agh.gt.metrics;

import pl.edu.agh.gt.data.RatesHistory;

/**
 * TODO
 */
public class Metrics {
	
	RatesHistory rates ;
	
	public Metrics(RatesHistory h) {
		this.rates= h;
	}

	public float movingAvg(int atPos, int backPeriod) {
		float sum = 0;
		for( int i = atPos - backPeriod + 1 ; i <= atPos ; i++ )
			sum += rates.getRate(i).getClose();
		return sum / backPeriod;
	}

	public float trend(int pos) {
		float val1 = movingAvg(pos, 10);
		float val2 = movingAvg(pos-2, 10);
		float val3 = movingAvg(pos-3, 10);
		
		return (val1 / val2 + val2/val3) / 2;
	}
	
	
	public float momentum(int lag) {
		return 0; //CLOSE(i)/CLOSE(i-N)*100
	}
}
